package com.tuo51.evaluate.vo.evaluate;

import com.tuo51.evaluate.domain.evaluatingV2.EvaluateV2Record;
import com.tuo51.foudation.utils.DateUtil;
import lombok.Data;

import java.util.Objects;

/**
 * *******************************
 * Created by Tim.
 * form com.matt
 * on 2017/12/21
 * *******************************
 */
@Data
public class WebEvaluateRecordListVo {

    private String evaluateRecordId;

    private String childrenName;

    private String gender;

    private Integer month;

    private String createTime;

    private String createTeacher;

    private String evaluateTime;

    private String evaluateTeacher;

    private String rating;

    private int dq;

    private Integer orderStatus;

    private Integer status;

    //测评发布状态：true-已发布 false-未发布
    private Boolean published;

    //
    private Boolean parentGranted = false;

    public static WebEvaluateRecordListVo of(EvaluateV2Record record) {
        WebEvaluateRecordListVo vo = new WebEvaluateRecordListVo();
        vo.setEvaluateRecordId(record.getId());
        vo.setChildrenName(record.getChildrenName());
        vo.setGender(record.getGender() == 0 ? "女" : "男");
        vo.setMonth(record.getMonth());
        vo.setCreateTime(DateUtil.millisToDateTime(record.getCreated().getTime(), "yyyy-MM-dd"));
        vo.setCreateTeacher(record.getCreateTeacherName());
        vo.setEvaluateTeacher(record.getEvaluatingTeacherName());
        if (Objects.nonNull(record.getEvaluatingDate())) {
            vo.setEvaluateTime(DateUtil.millisToDateTime(record.getEvaluatingDate().getTime(), "yyyy-MM-dd"));
            vo.setEvaluateTeacher(record.getEvaluatingTeacherName());
        }
        vo.setRating(record.getRating());
        vo.setDq(record.getDq());
        vo.setOrderStatus(record.getCategory());
        vo.setStatus(record.getStatus());
        vo.setPublished(record.getPublished());
        vo.setParentGranted(record.getParentGranted());
        return vo;
    }
}
